// 定义一个枚举
enum Color {
  Red,
  Green,
  Blue,
}

// 定义一个枚举，并指定其初始数值
enum Color2 {
  Red = 1,
  Green,
  Blue,
}

console.log(Color);
/* 
{ '0': 'Red', '1': 'Green', '2': 'Blue', Red: 0, Green: 1, Blue: 2 }
*/
console.log(Color2);
/* 
{ '1': 'Red', '2': 'Green', '3': 'Blue', Red: 1, Green: 2, Blue: 3 }
*/

// 定义一个phone变量，并设置对其进行限制
let phone: { name: string; price: number; color: Color };

phone = { name: "华为", price: 2000, color: Color.Red };
phone = { name: "iphone", price: 6000, color: Color.Green };

if (phone.color === Color.Red) {
  console.log("手机是红色的");
}
